package com.hgk.wanwan.regist.util;

import android.os.CountDownTimer;
import android.widget.TextView;

import width.hgk.wanwan.R;

/**
 * Created by lenovo on 2016/9/26.
 */
public class TimeCount extends CountDownTimer {
    /**
     * @param millisInFuture    The number of millis in the future from the call
     *                          to {@link #start()} until the countdown is done and {@link #onFinish()}
     *                          is called.
     * @param countDownInterval The interval along the way to receive
     *                          {@link #onTick(long)} callbacks.
     */
    private TextView mTvCountDowm;
    public TimeCount(long millisInFuture, long countDownInterval,TextView countView) {
        super(millisInFuture, countDownInterval);
        mTvCountDowm = countView;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        mTvCountDowm.setClickable(false);
        mTvCountDowm.setText(millisUntilFinished / 1000 + "秒后重新发");
        mTvCountDowm.setBackgroundResource(R.drawable.tel_code_bg_on);
    }

    @Override
    public void onFinish() {
        mTvCountDowm.setText("获取验证码");
        mTvCountDowm.setClickable(true);
        mTvCountDowm.setBackgroundResource(R.drawable.tel_code_bg);
    }
}
